package com.zbl.zblproject.erp.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnore;

import javax.validation.constraints.Min;
import java.math.BigDecimal;

/**
 * @author youlanqiang
 * @version 1.0
 * @date 2018/10/10
 * 出入库商品实体类
 */
@TableName("zbl_erp_orderitem")
public class ErpOrderItem {

    @TableId(type = IdType.AUTO)
    private int id;

    /**
     * 出入库单号ID
     */
    private int orderId;

    /**
     * 货物ID
     */
    private int goodsId;

    /**
     * 出入库货物数量
     */
    @Min(1)
    private int goodsNum;

    /**
     * 出入库价格
     */
    @Min(0)
    private BigDecimal goodsPrice;


    /**
     * 货位
     */
    private int goodsList;

    /**
     * 是否是赠送
     * 0 非赠送  1 赠送
     */
    private int isGive;

    /**
     * 欠货数量
     */
    private int oweNum;

    /**
     * 订单商品表中的ID
     */
    private int orderItemId;

    private int oweItem;

    @TableField(exist = false)
    private ErpWarehouse warehouse;

    @TableField(exist = false)
    private ErpGoods goods;

    @TableField(exist = false)
    @JsonIgnore
    private ErpInventoryOrderItem inventoryOrderItem;

    /**
     * 备注信息
     */
    private String defaultMsg;

    /**
     * 订单号
     */
    private String orderSn;

    /**
     * 商品名称
     */
    private String goodsName;

    /**
     * 品牌名称
     */
    private String brandName;

    /**
     * 供应商ID
     */
    private int suppliersId;

    public ErpOrderItem(){

    }

    public ErpOrderItem(int mode, ErpInventoryOrderItem orderItem){
        this.id = 0 - orderItem.getId();
        this.goodsId = orderItem.getGoodsId();
        this.goodsList = orderItem.getWhId();
        this.goodsPrice = orderItem.getInventoryPrice();
        if(mode == 0) {
            this.goodsNum = orderItem.getInventoryNum() - orderItem.getRealNum();
        }else{
            this.goodsNum = orderItem.getInventoryNum();
        }

        this.inventoryOrderItem = orderItem;
    }


    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getOrderId() {
        return orderId;
    }

    public void setOrderId(int orderId) {
        this.orderId = orderId;
    }

    public int getGoodsId() {
        return goodsId;
    }

    public void setGoodsId(int goodsId) {
        this.goodsId = goodsId;
    }

    public int getGoodsNum() {
        return goodsNum;
    }

    public void setGoodsNum(int goodsNum) {
        this.goodsNum = goodsNum;
    }

    public BigDecimal getGoodsPrice() {
        return goodsPrice;
    }

    public void setGoodsPrice(BigDecimal goodsPrice) {
        this.goodsPrice = goodsPrice;
    }

    public int getGoodsList() {
        return goodsList;
    }

    public void setGoodsList(int goodsList) {
        this.goodsList = goodsList;
    }


    public ErpGoods getGoods() {
        return goods;
    }

    public void setGoods(ErpGoods goods) {
        this.goods = goods;
    }


    public ErpWarehouse getWarehouse() {
        return warehouse;
    }

    public void setWarehouse(ErpWarehouse warehouse) {
        this.warehouse = warehouse;
    }

    public ErpInventoryOrderItem getInventoryOrderItem() {
        return inventoryOrderItem;
    }

    public void setInventoryOrderItem(ErpInventoryOrderItem inventoryOrderItem) {
        this.inventoryOrderItem = inventoryOrderItem;
    }

    public int getIsGive() {
        return isGive;
    }

    public void setIsGive(int isGive) {
        this.isGive = isGive;
    }

    public int getOrderItemId() {
        return orderItemId;
    }

    public void setOrderItemId(int orderItemId) {
        this.orderItemId = orderItemId;
    }

    public int getOweNum() {
        return oweNum;
    }

    public void setOweNum(int oweNum) {
        this.oweNum = oweNum;
    }

    public int getOweItem() {
        return oweItem;
    }

    public void setOweItem(int oweItem) {
        this.oweItem = oweItem;
    }

    public String getDefaultMsg() {
        return defaultMsg;
    }

    public void setDefaultMsg(String defaultMsg) {
        this.defaultMsg = defaultMsg;
    }

    public String getOrderSn() {
        return orderSn;
    }

    public void setOrderSn(String orderSn) {
        this.orderSn = orderSn;
    }

    public String getGoodsName() {
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getBrandName() {
        return brandName;
    }

    public void setBrandName(String brandName) {
        this.brandName = brandName;
    }

    public int getSuppliersId() {
        return suppliersId;
    }

    public void setSuppliersId(int suppliersId) {
        this.suppliersId = suppliersId;
    }

    @Override
    public String toString() {
        return "ErpOrderItem{" +
                "id=" + id +
                ", orderId=" + orderId +
                ", goodsId=" + goodsId +
                ", goodsNum=" + goodsNum +
                '}';
    }
}
